package com.test.resumeanalysis.data;

import androidx.room.TypeConverter;
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.test.resumeanalysis.data.model.resume.BasicInfo
import com.test.resumeanalysis.data.model.resume.EnglishParsingResult
import com.test.resumeanalysis.data.model.resume.ParsingResult

class Converter {
    private val gson = Gson()

    @TypeConverter
    fun EnglishFromString(value: String): EnglishParsingResult {
        val type = object : TypeToken<EnglishParsingResult>() {}.type
        return gson.fromJson(value, type)
    }

    @TypeConverter
    fun EnglishParsingResultToString(value: EnglishParsingResult): String {
        return gson.toJson(value)
    }

    @TypeConverter
    fun ParsingResultFromString(value: String):ParsingResult {
        val type = object : TypeToken<ParsingResult>() {}.type
        return gson.fromJson(value, type)
    }

    @TypeConverter
    fun  ParsingResultToString(value: ParsingResult): String {
        return gson.toJson(value)
    }
}